import { defineConfig } from 'vitepress'
import htmlSidebar from './sidebar/html'
import cssSidebar from './sidebar/css'
import jsSidebar from './sidebar/js'
import javaSidebar from './sidebar/java'
import sqlSidebar from './sidebar/sql'
import phpSidebar from './sidebar/php'
import oneDragon from './sidebar/one-dragon.js'
import react from './sidebar/react'

import filmTelevision from './sidebar/film-television'

import viteConfig from './vite.config.js';

// import { fileURLToPath, URL } from 'node:url'

// https://vitepress.dev/reference/site-config
export default defineConfig({

  // vite: {
  //   resolve: {
  //     alias: [{
  //       find: /^.*\/VPDocAsideOutline\.vue$/,
  //       replacement: fileURLToPath(
  //         new URL('./components/CustomAside.vue', import.meta.url)
  //       )
  //     }]
  //   }
  // },

  // vite: viteConfig,

  sitemap: {
    hostname: 'https://xiaosaturn.com',
  },

  /**
   * 当设置为 true 时，将页面元数据提取到单独的 JavaScript 块中，而不是内联在初始 HTML 中。
   * 这使每个页面的 HTML 负载更小，并使页面元数据可缓存，从而当站点中有很多页面时可以减少服务器带宽。
   */
  // metaChunk: true,

  // base: '/docs/',

  lastUpdated: true,

  head: [
    ['link', { rel: 'icon', href: '.vitepress/public/favicon.ico' }],
    ['link', { rel: 'icon', href: '/favicon.ico' }],
    //<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"/></pre></li>
    // ['link', { rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/@docsearch/css@3' }],
    // ['script', { src: 'https://cdn.jsdelivr.net/npm/@docsearch/js@3' }],
    // ['script', { type: 'text/javascript' }, `
    //     docsearch({
    //       appId: "I2AJ9HO0WZ",
    //       apiKey: "38848dc7ea9375130583b87e5cf9b052",
    //       indexName: "xiaosaturn",
    //       container: '#app',
    //       debug: true,
    //       placeholder: 'Search XiaoSaturn'
    //     });
    // `],
    // ['script', { type: 'text/javascript' }, `
    //     docsearch({
    //       appId: 'R2IYF7ETH7',
    //       apiKey: '599cec31baffa4868cae4e79f180729b',
    //       indexName: 'docsearch',
    //     });
    // `],
  ],

  /**
   * 当设置为 true 时，VitePress 不会因为死链而导致构建失败。
   * 当设置为 'localhostLinks' ，出现死链时构建将失败，但不会检查 localhost 链接。
   * https://vitepress.dev/zh/reference/site-config
   */
  ignoreDeadLinks: true,

  locales: {
    root: {
      title: 'MasterH',
      description: '',
      label: 'English',
      lang: 'en',
      themeConfig: {
        nav: [
          { text: 'Home', link: '/' },
          {
            text: 'Learn English By AI',
            link: '/english/'
          },
          // {
          //   text: 'History', items: [
          //     {
          //       text: 'China Ancient History',
          //       link: '/history/ancient-china/'
          //     }, {
          //       text: 'China Modern History',
          //       link: '/history/modern-china/'
          //     }, {
          //       text: 'World Ancient History',
          //       link: '/history/ancient-world/',
          //     }, {
          //       text: 'World Modern History',
          //       link: '/history/modern-world/',
          //     }
          //   ]
          // },
          // {
          //   text: 'Film&Television', items: [
          //     {
          //       text: 'Film & Television & Music',
          //       link: '/film-television-music/'
          //     }
          //   ]
          // },
          {
            text: 'Technology', items: [{
              text: 'Frontend',
              items: [{
                text: 'HTML',
                link: '/tech/frontend/html/',
              }, {
                text: 'CSS',
                link: '/tech/frontend/css/'
              }, {
                text: 'JavaScript',
                link: '/tech/frontend/js/'
              }, {
                text: 'React',
                link: '/tech/frontend/react/'
              }, {
                text: 'Vue',
                link: '/tech/frontend/vue/'
              }]
            }, {
              text: 'Backend',
              items: [{
                text: 'Java',
                link: '/tech/backend/java/'
              }, {
                text: 'SQL',
                link: '/tech/backend/sql/'
              }, {
                text: 'PHP',
                link: '/tech/backend/php/'
              }]
            }]
          },
          // {
          //   text: 'Diary',
          //   items: [{
          //     text: '2024',
          //     link: '/diary/2024/'
          //   }]
          // },
          { text: 'About Me', link: '/about' }
        ],
      }
    },
    zh: {
      title: "黄大师",
      description: "",
      label: '中文',
      lang: 'zh',
      link: '/zh/',
      themeConfig: {
        nav: [
          { text: '首页', link: '/zh/' },
          {
            text: '历史', items: [
              {
                text: '中国古代史',
                link: '/zh/history/ancient-china/'
              }, {
                text: '中国近代史',
                link: '/zh/history/modern-china/'
              }, {
                text: '世界古代史',
                link: '/zh/history/ancient-world/',
              }, {
                text: '世界近代史',
                link: '/zh/history/modern-world/',
              }
            ]
          },
          {
            text: '影视剧', items: [
              {
                text: '影视剧和音乐',
                link: '/zh/film-television-music/'
              }
            ]
          },
          {
            text: '技术', items: [{
              text: '知识一条龙',
              link: '/zh/tech/one-dragon/'
            }, {
              text: '前端',
              items: [{
                text: 'HTML',
                link: '/zh/tech/frontend/html/',
              }, {
                text: 'CSS',
                link: '/zh/tech/frontend/css/'
              }, {
                text: 'JavaScript',
                link: '/zh/tech/frontend/js/'
              }, {
                text: 'React',
                link: '/zh/tech/frontend/react/'
              }, {
                text: 'Vue',
                link: '/zh/tech/frontend/vue/'
              }]
            }, {
              text: '后端',
              items: [{
                text: 'Java',
                link: '/zh/tech/backend/java/'
              }, {
                text: 'SQL',
                link: '/zh/tech/backend/sql/'
              }, {
                text: 'PHP',
                link: '/zh/tech/backend/php/'
              }
              ]
            }]
          },
          {
            text: '工具', items: [
              {
                text: '概览',
                link: '/zh/tools/'
              }, {
                text: '导航',
                link: '/zh/tools/nav'
              }, {
                text: '软件',
                link: '/zh/tools/software'
              }
            ]
          },
          {
            text: '日常记录',
            items: [
              {
                text: '2024',
                link: '/zh/2024'
              }, {
                text: '2025',
                link: '/zh/2025'
              }
            ]
          },
          { text: '关于我', link: '/zh/about' }
        ],
        search: {
          provider: 'algolia',
          options: {
            appId: 'I2AJ9HO0WZ',
            apiKey: '38848dc7ea9375130583b87e5cf9b052',
            indexName: 'xiaosaturn',
            placeholder: '搜索你感兴趣的内容',
            translations: {
              button: {
                buttonText: '搜索'
              }
            }
          }
        },
      }
    }
  },

  markdown: {
    image: {
      lazyLoading: true
    },
  },

  themeConfig: {
    search: {
      provider: 'algolia',
      options: {
        appId: 'I2AJ9HO0WZ',
        apiKey: '38848dc7ea9375130583b87e5cf9b052',
        indexName: 'xiaosaturn',
        placeholder: 'Search for content that you are interested in'
      }
    },

    // https://vitepress.dev/reference/default-theme-config

    sidebar: {
      ...javaSidebar,
      ...sqlSidebar,
      ...htmlSidebar,
      ...cssSidebar,
      ...jsSidebar,
      ...phpSidebar,
      ...filmTelevision,
      ...oneDragon,
      ...react,
    },


    // socialLinks: [
    //   { icon: 'github', link: 'https://github.com/vuejs/vitepress' }
    // ]
  },


})
